﻿using AutoMapper;
using MediatR;
using Traceability.APP.Application.Command.Pictures;
using Traceability.Damoin;
using Traceability.ErrorCode;
using Traceability.Infaseture;

namespace Traceability.APP.Application.CommandHadnLer.Price
{
    public class DeletepictureCommandHandLer : IRequestHandler<DeletepictureCommand, APIResult<int>>
    {

        private readonly IBaseRepostiy<Picture> _picture;

        public DeletepictureCommandHandLer(IBaseRepostiy<Picture> picture, IMapper mapper)
        {
            _picture = picture;

        }
        public async Task<APIResult<int>> Handle(DeletepictureCommand request, CancellationToken cancellationToken)
        {
            APIResult<int> result = new APIResult<int>();
            var list =await _picture.GetValues(x => x.Id == request.Id);
            await _picture.Delete(list);
            result.Code = ResultCode.Ok;
            result.Message = "图片删除成功";
            result.Data = 1;
            return await Task.FromResult(result);
        }
    }
}
